package com.itheima.tlias84.aop.cglib;

import org.springframework.cglib.proxy.Enhancer;

public class TestCglib {
    public static void main(String[] args) {
        //1、创建增强器对象
        Enhancer enhancer = new Enhancer();
        //2、给增强器设置要代理的父类:被增强的父类
        enhancer.setSuperclass(Dog.class);
        //3、创建方法拦截器：实现MethodInterceptor接口-->EatInterceptor类
        //4、拦截器回调
        enhancer.setCallback(new EatInterceptor());
        //5、创建代理对象-->强转成父类-Dog
//        Object object = enhancer.create();
        Dog dog = (Dog) enhancer.create();
        dog.eat();

    }


}
